#include <bits/stdc++.h>
using namespace std;
int num[3003];

int main() {
	int n, m;
	int ans = 0X7FFFFFF;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
	}
	for (int i = 0; i < n - m + 1; ++i) {
		int sum = 0;
		for (int j = i; j < m + i; ++j) {
			sum += num[j];
		}
		if (sum < ans) {
			ans = sum;
		}
	}
	cout << ans;
	return 0;
}